﻿<UserControl x:Class="FXSStation.Modules.SettingsModule.AccountSettingsView"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
   >
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="0.5*"/>
            <RowDefinition Height="0.5*"/>
            <RowDefinition Height="0.5*"/>
            <RowDefinition Height="1*"/>
            <RowDefinition Height="1*"/>
            <RowDefinition Height="1*"/>
            <RowDefinition Height="50"/>
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="0.5*"/>
            <ColumnDefinition Width="0.5*"/>
        </Grid.ColumnDefinitions>
        <StackPanel Margin="0,0,0,0" Grid.Column="1" VerticalAlignment="Center">
            <RadioButton Content="Testing" Name="rbTesting" GroupName="Mode" IsChecked="True" ToolTip="Testing Mode generates data runtime"/>
            <RadioButton Content="History" Name="rbHistory" GroupName="Mode" ToolTip="History Mode display chronological data"/>
        </StackPanel>
        <ComboBox IsSynchronizedWithCurrentItem="True" Margin="0,0,0,0" Grid.Column="1" Grid.Row="1" Height="30" x:Name="comboCurrencyPair" ToolTip="Select Currency Pair" SelectedIndex="0"/>
        <ComboBox IsSynchronizedWithCurrentItem="True" Margin="0,0,0,0" Grid.Column="1" Grid.Row="2" Height="30" x:Name="comboTickFrequency" ToolTip="Select Tick Frequency - in minutes" SelectedIndex="3"/>
        <TextBlock Margin="0,0,0,0" Text="Mode :" TextWrapping="Wrap" VerticalAlignment="Center" HorizontalAlignment="Left"/>
        <TextBlock Margin="0,0,0,0" Grid.Row="1" Text="Currency pair" TextWrapping="Wrap" VerticalAlignment="Center"/>
        <TextBlock Margin="0,0,0,0" Grid.Row="2" Text="Tick Frequency" TextWrapping="Wrap" VerticalAlignment="Center" ToolTip="Tick Frequency is in minutes"/>
        
        <TreeView Name="listAccounts" Background="Transparent"  Foreground="White"
                  TreeViewItem.Selected="listAccounts_Selected" 
                  ItemsSource="{Binding Accounts}" Height="200" Grid.Row="3" Grid.ColumnSpan="2">            
            <TreeView.ItemTemplate>
                <HierarchicalDataTemplate  ItemsSource="{Binding Sessions}">
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="0.5*"/>
                            <ColumnDefinition Width="0.5*"/>
                        </Grid.ColumnDefinitions>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="0.2*"/>
                            <RowDefinition Height="0.3*"/>
                            <RowDefinition Height="0.5*"/>
                        </Grid.RowDefinitions>
                        <TextBlock  Grid.ColumnSpan="2" Grid.Row="0" Text="{Binding Name}" FontWeight="Bold" 
                                    HorizontalAlignment="Stretch"/>
                        <TextBlock  Grid.Column="0" Grid.Row="1" Text="Deposit" FontWeight="Bold" HorizontalAlignment="Left"/>
                        <TextBlock  Grid.Column="1" Grid.Row="1" Text="{Binding Balance.Deposit}"/>
                        <TextBlock  Grid.Column="0" Grid.Row="2" Text="Sessions" FontWeight="Bold" HorizontalAlignment="Left" />
                        <TextBlock  Grid.Column="1" Grid.Row="2" Text="{Binding Sessions.Count}"/>
                    </Grid>
                    <HierarchicalDataTemplate.ItemTemplate>
                        <HierarchicalDataTemplate>
                            <Grid>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="0.1*"/>
                                    <ColumnDefinition Width="0.2*"/>
                                    <ColumnDefinition Width="0.1*"/>
                                    <ColumnDefinition Width="0.6*"/>
                                </Grid.ColumnDefinitions>
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="0.2*"/>
                                    <RowDefinition Height="0.3*"/>
                                    <RowDefinition Height="0.5*"/>
                                </Grid.RowDefinitions>
                                <CheckBox Grid.Column="0" HorizontalAlignment="Center" VerticalAlignment="Center" Grid.Row="0" IsEnabled="False" IsChecked="{Binding IsOpen}"/>
                                <!--<TextBlock Grid.Column="1" Text="Session" FontWeight="Bold" FontStyle="Italic" FontSize="14" />-->
                                <TextBlock Grid.Column="2" Text="{Binding TimeStampStart, StringFormat='{} Start {0:d}'}"/>
                                <TextBlock Grid.Column="3" Text="{Binding TimeStampEnd, StringFormat='{} End {0:d}'}"/>
                                <TextBlock Grid.Column="2" Grid.Row="1" Text="Active Orders" FontWeight="Bold"/>
                                <TextBlock Grid.Column="3" Grid.Row="1" Text="Closed Orders" FontWeight="Bold"/>
                                <TextBlock Grid.Column="2" Grid.Row="2" Text="{Binding ActiveOrders.Count}" FontStyle="Italic"/>
                                <TextBlock Grid.Column="3" Grid.Row="2" Text="{Binding ClosedOrders.Count}" FontStyle="Italic"/>
                            </Grid>
                        </HierarchicalDataTemplate>
                    </HierarchicalDataTemplate.ItemTemplate>
                </HierarchicalDataTemplate>
            </TreeView.ItemTemplate>
        </TreeView>

        <!--IMPORTATNT-->
        <!--This has been replaced with a TreeView as we are giving the user 
        the ability to see extended information about his account.
        
        This also opens the possibility of a quicker reopening of a CLOSED session-->
        <!--<ListView Name="listAccounts" ItemsSource="{Binding Accounts}" Height="Auto" Grid.Row="3" Grid.ColumnSpan="2" SelectedIndex="0">
            <ListView.View>
                <GridView>
                    <GridViewColumn DisplayMemberBinding="{Binding Path=Name}"/>
                    <GridViewColumn DisplayMemberBinding="{Binding Path=Balance.Deposit}"/>
                    <GridViewColumn DisplayMemberBinding="{Binding Path=Sessions.Count}"/>
                </GridView>
            </ListView.View>
        </ListView>-->
        
        <!--Row 4-->
        <Button Margin="0,0,0,0" Click="OnSimulationinItialized" Content="New Simulation" Grid.Row="4" Grid.ColumnSpan="2" VerticalAlignment="Center" HorizontalAlignment="Center" Width="150" ToolTip="Start Simulation"/>
        
        
        <!--Row 5--> 
        <Expander IsExpanded="False" Header="New Account..." Grid.Row="5" Grid.ColumnSpan="2">
            <DockPanel>
                <StackPanel DockPanel.Dock="Left">
                    <TextBlock Text="Username:"/>
                    <TextBlock Text="Description:"/>
                </StackPanel>
                <StackPanel DockPanel.Dock="Left">
                    <TextBox x:Name="tbUsername"/>
                    <TextBox x:Name="tbDescription"/>
                    <Button Content="Create" Click="OnAccountCreated" />
                </StackPanel>
            </DockPanel>
        </Expander>
        
        <!--Row 6 - Placeholder-->
    </Grid>
</UserControl>
